<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>订单统计</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">
    <link href="<%=path %>/hplus/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="<%=path %>/hplus/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="<%=path %>/hplus/css/animate.min.css" rel="stylesheet">
    <link href="<%=path %>/hplus/css/style.min862f.css?v=4.1.0" rel="stylesheet">
        <link href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"><link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/font-awesome.min93e3.css?v=4.4.0"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/datapicker/datepicker3.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/style.min.css"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet">
    <style>
        .col-sm-1{
            padding-right: 0;
        }
        .label1{
                line-height: 2.1;
        	}
        .pie1{
    		margin-top: 20px;
    		 height: 500px;
    		 margin-left:18px;
    		 margin-right:18px;
        }
        .label2{
        	height: 34px;
   text-align-last: center;
    width: 50px;
    margin-left: -243px;
    line-height: 20px;
    background-color: #EAEAEA;
        }
        .label3{
        height: 34px;
   text-align: center;
 /*   width: 50px;
     margin-left: -250px;
 */    line-height: 20px;
    background-color: #EAEAEA;
        }
        .order{
        	   line-height: 2;
        }
        input.uploadFile{
            position: absolute;
            opacity: 0;
            width: 100%;
            height: 100%;
            left: 0;
            top: 0;
            line-height: 0;
            padding-left: 0;
            margin-left: 0;
        }
        .uploadBtn{
            width: 60px;
            display: inline-block;
            background: #1ab394;
            color: #fff;
            border-radius: 3px;
            height: 36px;
            line-height: 36px;
            border: none;
            font-size: 14px;
        }
        .s_address{
            height: 340px;
            background:#eee;
        }
        .red{
            color: red;
            margin-right: 5px;
        }
		body{
			font-size:14px;
			
		}
		ol{
  		list-style:none;
  	}
  	li{
  		list-style:none;
  	}
  	.tb{
  		margin-top:20px;
  	}
JSON
body {font-size: 14px;padding: 20px;}
.radio-primary input[type="radio"] + label::after {background-color: #1ab394;}
.radio-primary input[type="radio"]:checked + label::after {background-color: #1ab394;}
.radio-primary input[type="radio"]:checked + label::before {border-color: #1ab394;}
form>div.row{margin-bottom: 16px;}
a.btn-rounded{margin-right: 16px;}
a:hover{
	background-color:red;
	color:red;
}
    </style>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content">
     <div class="tabs-container">
	    <ul class="nav nav-tabs">
	                <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">小票拦截统计</a>
	                </li>
	                <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">小票拦截查询</a>
	                </li>
	                <li class=""><a data-toggle="tab" href="#tab-3" aria-expanded="false">小票弹窗</a>
	                </li>
	     </ul>
	     <div class="tab-content">
	     <div class="ibox-content tab-pane active" id="tab-1">
		 <form method="post" class="form-horizontal"  id='share_image'>
			<div class="form-group order">
					<label class="col-sm-1 control-label label1" >小票输出订单:</label>
					<label class="col-sm-7"><span id="count" style="font-size:20px;color:#58C8B1;"></span>单</label>
					<div class="form-group">
                    <div class="col-sm-3 col-sm-offset-1">            
                    	<button type="button" class=" btn btn-outline btn-primary col-sm-4" id="close" style="margin-right:20px;" organizationImg="">重置</button>   
                    	&nbsp;&nbsp;&nbsp;&nbsp;         
						<button type="button" class=" btn btn-primary k_verify col-sm-4" id="commit">确认</button>
                    </div>
                </div>
				</div>
			<div class="form-group">					
                    <label class="col-sm-1 control-label">门&nbsp;&nbsp;店&nbsp;&nbsp;</label>
                    <div class="col-sm-4">
                       <select class="form-group form-control" id="store_id">
						<option value="">全部</option>
					   </select>
                    </div>
					<label class="col-sm-1 control-label">款&nbsp;&nbsp;员&nbsp;&nbsp;&nbsp;&nbsp;</label>
                    <div class="col-sm-2">
                       <select class="form-group form-control" id="cashier_id">
						<option value="">全部</option>
					   </select>
                    </div>
                </div>
				<div class="form-group">
					 <label class="col-sm-1 control-label">交易时间&nbsp;&nbsp;</label>
					 <div class="form-group col-sm-5">
					 	<div class="input-daterange date form-group col-sm-12">
							 <div class=" col-sm-5" style="height: 34px;background-color: #EAEAEA;">
								   <input class="form-group form-control" id="startDate" style="min-width: 100px;"/>							  	
							 </div>		
							 <div class="col-sm-1" style="background-color: #EAEAEA;">
							  	<label class="form-group control-label label3">到</label>
							</div>
							  <div class="col-sm-5" >
								   <input class="form-group form-control" id="endDate" style="min-width: 100px;"/>		
							  </div>
						</div>						
					</div>					 
                </div>
				    </form>				
				<div class="form-group">	
				<div class="pie1">
				<div class="row pie" style="height:500px;background-color: white;margin-bottom: 20px;">
					<div class="col-sm-1"></div>
					<div class="col-sm-5">
						<div id="register" style="height: 300px;"></div>
					</div>
					<div class="col-sm-5">
						<div id="element" style="height: 300px;"></div>
					</div>
				</div>
				</div>
				</div>
				<!-- <div class="form-group">
					<div class="form-group col-sm-2"></div>
					<div class="form-group col-sm-3 echarts" id="register">						
					</div>
					<div class="form-group">
						<div class="form-group col-sm-2"></div>
						<div class="form-group col-sm-3 echarts" id="element">										
					</div>
				</div> -->
		</div>
		<div class="tab-pane" id="tab-2">
		<div class="panel-body">
		<div class="ibox-content" style="margin-top: -21px;">
		 <form method="post" class="form-horizontal"  id='share_image1'>	 
			<div class="form-group order">
				<div class="col-sm-12" style="margin-top: 20px;"></div>
					<label class="col-sm-1 control-label">小票单号&nbsp;</label>
				<div class="col-sm-4">
					<input type="text" class="form-group form-control" id="order_number"/>		
				</div>
				<div class="col-sm-2"></div>
					<div class="form-group">
                    <div class="col-sm-3 col-sm-offset-1">            
                    	<button type="button" class=" btn btn-outline btn-primary col-sm-4" id="closeSearch" style="margin-right:20px;" organizationImg="">重置</button>   
                    	&nbsp;&nbsp;&nbsp;&nbsp;         
						<button type="button" class=" btn btn-primary k_verify col-sm-4" id="commitSearch">确认</button>
                    </div>
                </div>
				</div>
			<div class="form-group">					
                    <label class="col-sm-1 control-label">门&nbsp;&nbsp;店&nbsp;&nbsp;</label>
                    <div class="col-sm-4">
                       <select class="form-group form-control" id="store_id1">
						<option value="">全部</option>
					   </select>
                    </div>
					<label class="col-sm-1 control-label">款&nbsp;&nbsp;员&nbsp;&nbsp;&nbsp;&nbsp;</label>
                    <div class="col-sm-2">
                       <select class="form-group form-control" id="cashier_id1">
						<option value="">全部</option>
					   </select>
                    </div>
                </div>
				<div class="form-group">
					 <label class="col-sm-1 control-label">交易时间&nbsp;&nbsp;</label>
					 <div class="form-group col-sm-5">
					 	<div class="input-daterange date form-group col-sm-12">
							 <div class=" col-sm-5" style="height: 34px;background-color: #EAEAEA;">
								   <input  class="form-group form-control" style="min-width: 100px;"id="startDate1"/>							  	
							 </div>		
							 <div class="col-sm-1" style="background-color: #EAEAEA;">
							  	<label class="form-group control-label label3">到</label>
							</div>
							  <div class="col-sm-5" >
								   <input class="form-group form-control"  id="endDate2" style="min-width: 100px;"/>		
							  </div>
						</div>						
					</div>	
                </div>
				<div class="form-group">
					<div  >
					 <label class="col-sm-2 control-label"><input type="checkbox" id="term1">注册新会员</label>
					 </div>
					 <div >
					 <label class="col-sm-2 control-label"><input type="checkbox" id="term2">录入体质标签</label>
					 </div>
                </div>
				</div>
				<div class="ibox-content tb">
				<div class="form-group">
					<div class="col-sm-12">
						<table class="table table-bordered" id="myTable" style="width:100%;">
							<thead>
							 <tr>
								<th>小票单号</th>
								<th>交易时间</th>
								<th>门店名称</th>
								<th>款员</th>
								<th>预购商品</th>
								<th>购买数量</th>
								<th>总金额</th>
								<th>会员信息</th>
								<th>注册新会员</th>
								<th>体质标签</th>
							 </tr>
							</thead>
							<tbody>
								<!--  <tr>
									<td>D00001</td>
									<td>2017-10-11</td>
									<td>08:10:45</td>
									<td>康寿堂大望路店</td>
									<td>晓虎</td>
									<td>蒲地兰消炎片</td>
									<td>1盒</td>
									<td>50</td>
									<td>是</td>
									<td>高血压</td>
								</tr>
								<tr>
									<td>D00002</td>
									<td>2017-10-11</td>
									<td>08:10:45</td>
									<td>康寿堂大望路店</td>
									<td>晓虎</td>
									<td>蒲地兰消炎片</td>
									<td>1盒</td>
									<td>50</td>
									<td>是</td>
									<td>高血压</td>
								</tr>
								-->
							</tbody>
						</table>
					</div>
				</div>
			</form>
		</div>
		</div>
		<!-- <a href="javaScript:void(0)" id="time">点击</a> -->
		</div>
		<div class="tab-pane" id="tab-3">
			<div class="container-fluid" style="padding-top: 40px;background-color: white;">
	<form method="get" class="form-horizontal">
		<div class="row">
			<label class="col-sm-2 control-label">完善会员信息：</label>
			<div class="col-sm-1 control-label" style="text-align: left;">手机号</div>
			<div class="col-sm-3">
		        <input id="phone" type="text" class="form-control">
		    </div>
		</div>
		<div class="row">
			<div class="col-sm-offset-2 col-sm-1 control-label" style="text-align: left;">姓名</div>
			<div class="col-sm-3">
		        <input id="name" type="text" class="form-control">
		    </div>
		</div>
		<div class="row">
			<div class="col-sm-offset-2 col-sm-1 control-label" style="text-align: left;">性别</div>		
			<div class="col-sm-1">
	            <div class="radio radio-primary"  style="margin-left:0px;">
	                <input id="a" type="radio" name="sex" value="m" checked="checked">
	                <label for="a">男</label>
	            </div>
	        </div>
	        <div class="col-sm-1">
	            <div class="radio radio-primary" >
	                <input id="b" type="radio" name="sex" value="f">
	                <label for="b">女</label>
	            </div>
	        </div>
		</div>
		<div class="row">
			<div class="col-sm-offset-2 col-sm-1 control-label" style="text-align: left;">生日</div>
			<div class="col-sm-1">
	            <select class="form-control year" onchange="func_getDay()">
	            </select>
	        </div>
	        <div class="col-sm-1" style="padding-left:px;">
	            <span style="line-height:34px;">年</span>
	        </div>
	        <div class="col-sm-1" style="margin-left: -60px;">
	            <select class="form-control month" onchange="func_getDay()">
	            </select>
	        </div>
	        <div class="col-sm-1" style="padding-left:0;">
	            <span style="line-height:34px;">月</span>
	        </div>
	        <div class="col-sm-1"  style="margin-left: -80px;">
	            <select class="form-control day">
	            </select>
	        </div>
	        <div class="col-sm-1" style="padding-left:0;">
	            <span style="line-height:34px;">日</span>
	        </div>
		</div>
		<div class="row">
			
			<label class="col-sm-2 control-label">体质标签：</label>
			<div class="col-sm-8" >
				<div class="form-group" style="margin-left:80px;">					
					 <label class="col-sm-1 control-label"><input type="checkbox" id="tag1" value="老">&nbsp;老</label>
					 <label class="col-sm-1 control-label"><input type="checkbox" id="tag2" value="幼">&nbsp;幼</label>
					 <label class="col-sm-1 control-label"><input type="checkbox" id="tag3" value="孕">&nbsp;孕</label>
					 <label class="col-sm-1 control-label"><input type="checkbox" id="tag4" value="残">&nbsp;残</label>
                </div>
			</div>
		</div>
		<div class="row">
			<label class="col-sm-2 control-label">购药信息：</label>
			<div class="col-sm-1"></div>
			<div class="col-sm-8" id="medicine">
				<p>药品：扑尔敏片</p>
				<p>数量：1盒</p>
			</div>
		</div>
		<div class="row" >
		<label class="col-sm-2 control-label">发送购药提醒：</label>
		<div style="margin-left:280px;" id="sms">
		<div class="tabs-container"    style=" margin-left: 40px;">
		<div>
	    <ul class="nav nav-tabs">
	                <li class="active"><a data-toggle="tab" href="#tab-10" aria-expanded="true">购药提醒</a>
	                </li>
	                <li class=""><a data-toggle="tab" href="#tab-11" aria-expanded="false">用药禁忌</a>
	                </li>
	                <li class=""><a data-toggle="tab" href="#tab-12" aria-expanded="false">用药依从</a>
	                </li>
	                <li class=""><a data-toggle="tab" href="#tab-13" aria-expanded="false">药终关怀评价</a>
	                </li>
	     </ul>
	     </div>
		     <div class="tab-content" style="    margin-left: -20px;">
		     
					<div class="ibox-content tab-pane active" id="tab-10">
					<textarea style='width: 100%;height: 120px;padding: 20px; margin-top: -15px;' id='smsText'>[永安堂大药房]亲爱的会员名称,您于时间购买了药品名称，数量。点击药品说明链接获取详细用药说明和更多健康服务。     
					</textarea>
					</div> 
					<div class="ibox-content tab-pane " id="tab-11">
					<textarea style='width: 100%;height: 120px;padding: 20px; margin-top: -15px;' id='smsText'>[永安堂大药房]亲爱的会员名称,鉴于您正在服用药品名称，为了保证药品疗效和您的身体健康，请注意用药禁忌，点击用药禁忌链接获取详细禁忌说明。
					</textarea>
					</div>
					<div class="ibox-content tab-pane " id="tab-12">
					<textarea style='width: 100%;height: 120px;padding: 20px; margin-top: -15px;' id='smsText'>[永安堂大药房]亲爱的会员名称,为保护您的健康,建议您根据医嘱或药品说明按时服药,不可擅自停药。如需要了解更多健康常识,可来店咨询店内药师。
					</textarea>
					</div>
					<div class="ibox-content tab-pane " id="tab-13">
					<textarea style='width: 100%;height: 120px;padding: 20px; margin-top: -15px;' id='smsText'>[永安堂大药房]亲爱的会员名称,根据药物常规用法,您上次在我们药店购买的药品名称可能即将服用完，请根据您的康复状况续购药品。同时特邀您为我们的服务进行评价，点击药终评价链接评价，第一时间获得优惠信息。					</textarea>
					</div>
				</div>
		</div>
		</div>
		</div>
		<div class="row">
			<div class="col-sm-11 text-center">
			</div>
		</div>
	</form>
</div>
		</div>
	</div>
	</div>
	</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="<%=path %>/hplus/js/content.min.js?v=1.0.0"></script>
    <script src="<%=path %>/hplus/js/plugins/chosen/chosen.jquery.js"></script>
    <script src="<%=path %>/hplus/js/plugins/jsKnob/jquery.knob.js"></script>
    <script src="<%=path %>/hplus/js/plugins/jasny/jasny-bootstrap.min.js"></script>
    <script src="<%=path %>/hplus/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    <script src="<%=path %>/hplus/js/plugins/prettyfile/bootstrap-prettyfile.js"></script>
    <script src="<%=path %>/hplus/js/plugins/nouslider/jquery.nouislider.min.js"></script>
    <script src="<%=path %>/hplus/js/plugins/switchery/switchery.js"></script>
    <script src="<%=path %>/hplus/js/plugins/ionRangeSlider/ion.rangeSlider.min.js"></script>
    <script src="<%=path %>/hplus/js/plugins/iCheck/icheck.min.js"></script>
    <script src="<%=path %>/hplus/js/plugins/metisMenu/jquery.metisMenu.js"></script>
    <script src="<%=path %>/hplus/js/plugins/colorpicker/bootstrap-colorpicker.min.js"></script>
    <script src="<%=path %>/hplus/js/plugins/clockpicker/clockpicker.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/3.6.1/echarts.min.js"></script>
 	 <script src="<%=path%>/hplus/js/plugins/cropper/cropper.min.js"></script>   
    <script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/js/jquery.dataTables.min.js"></script>
    <script src="<%=path%>/hplus/js/demo/form-advanced-demo.min.js"></script>
	<script src="<%=path%>/hplus/js/plugins/suggest/bootstrap-suggest.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
    <script src="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.js"></script>
	<script type="text/javascript" src="<%=path%>/js/marketing/public.js"></script>
	<script>
	var path = "<%=path%>";
    var myDataTable;
	var storeId;
	var cashierId;
	var startDate;
	var endDate;
	var orderNumber;
	var storeId1;
	var cashierId1;
	var startDate1;
	var endDate1;
	//0代表都不查 1代表注册会员 2 代表录入体质 3代表全选
	var flag=0;
    var access_token=$.cookie('access_token');
   	var cid=$.cookie('cid');
   	var uid=$.cookie('uid');
   	var id=getQueryString("id");
	var userUrl="<%=path%>/ser/order/getUserCount";
	var tagUrl="<%=path%>/ser/order/getTagCount";	
	$(function(){
    	init();
        $(".input-daterange").datepicker({keyboardNavigation: !1, forceParse: !1, autoclose: !0});
	})
		function charPie(id, text,data1,data2) {
			var myChart = echarts.init(document.getElementById(id));
			// 指定图表的配置项和数据
		    var option = {
		        title: {
		            text: text,
		            x:"center"
		        },
		        tooltip: {},
		        legend: {
		        	x:"center",
		        	y:"bottom",
		            data:data1
		        },
		        series: [
		            {
		                name:text,
		                type:'pie',
		                radius: ['45%', '70%'],
		                avoidLabelOverlap: false,
		                label: {
		                    normal: {
		                        show: false,
		                        position: 'center'
		                    },
		                    emphasis: {
		                        show: true,
		                        textStyle: {
		                            fontSize: '20',
		                            fontWeight: 'bold'
		                        }
		                    }
		                },
		                labelLine: {
		                    normal: {
		                        show: false
		                    }
		                },
		                data:data2.data2
		            }
		        ],
		        color : [ '#1ab394', '#76d2bf', '#bae9df' ]
		    }; 
			myChart.setOption(option);
		}
	function init(){
		$.post(userUrl,{
			"storeId":storeId,
			"cashierId":cashierId,
			"startDate":startDate,
			"endDate":endDate
		},function(data){ 
			data=JSON.parse(data);
			charPie('register',"注册会员占比",["未注册会员","注册会员","未知"],data.data);
		},"json");
		$.post(tagUrl,{
			"storeId":storeId,
			"cashierId":cashierId,
			"startDate":startDate,
			"endDate":endDate
		},function(data){
			data=JSON.parse(data);
			//console.log(data.data);
			charPie('element',"录入体质占比",["未录入体质","录入体质","未知"],data.data);
		},"json");
		var countUrl="<%=path%>/ser/order/getCount";
		$.post(countUrl,{
			"storeId":storeId,
			"cashierId":cashierId,
			"bak1":startDate,
			"bak2":endDate
		},function(data){
			//console.log(data);
  			$("#count").text(data);
  		});
	}
					$("#commit").click(function(){
					var data=$("#store_id").val();
					if(data!=null&&data!=""){
						storeId=data;
					}
					data=$("#cashier_id").val();
					if(data!=null&&data!=""){
						cashierId=data;
					}
					data=$("#startDate").val();
					if(data!=null&&data!=""){
						startDate=data;
					}
					data=$("#endDate").val();
					if(data!=null&&data!=""){
						endDate=data;
					}
					init();
				});
				$("#close").click(function(){
					/* $("#order_number").prop("value","");
		    		$("#startDate").prop("value","");
		    		$("#endDate").prop("value","");
		    		$("#store_id option:first").prop("selected", 'selected');
		    		$("#cashier_id option:first").prop("selected", 'selected'); */
					window.location.reload();
				});    
        function dataTable(){
        	return $('#myTable').DataTable({
        		processing: true,
        		//ordering: false,
        		searching: false,
        		info: true,
        		autoWidth: true,
        		lengthChange: false,
        	    language: {
        	    	emptyTable: '<div id="content_empty"  class="form-group white-bg" style="text-align:center;padding:200px 0;margin:0;">   <p>暂无点击数据</p></div>',
        	    	info: '从第 _START_ 到第 _END_ 条数据；总共有 _TOTAL_ 条记录',
        			infoEmpty: '没有数据',
        			lengthMenu: '每页显示 _MENU_ 条记录',
        			loadingRecords: '正在加载数据....',
        			processing: '正在处理数据....',
        			zeroRecords: '没有找到匹配的记录',
        			paginate: {
        				first: '首页',
        				previous: '前页',
        				next: '后页',
        				last: '尾页'
        			}
        	    },
        		pageLength: 6,
        	    pagingType: 'full_numbers',        	     
        	    columns: func_columns(),
        	     columnDefs: [{
        	    	　　　　'targets' : [0,2,3,4,5,6,7,8],    //除第六，第七两列外，都默认不排序
        	    	　　　　'orderable' : false
        	    	　　},{
        			render: function(data, type, full) {
        				var json=JSON.parse(data);
        				var result='<ol>';
        				for(var i=0;i<json.length;i++){
        					result+="<li>"+json[i].goodsName+"</li>";
        				}           
        				return result;
                    },
        			targets: 4
        		},{
        			render: function(data, type, full) {
        				var json=JSON.parse(data);
        				var result='<ol>';
        				for(var i=0;i<json.length;i++){
        					result+="<li>"+json[i].purchaseQuantity+"盒</li>";
        				}           
        				return result;
                    },
        			targets: 5
        		},{
        			render: function(data, type, full) {
        				var json=JSON.parse(data);
        				var result='<ol>';
        				for(var i=0;i<json.length;i++){
        					result+="<li>"+json[i].tagName+"</li>";
        				}           
        				return result;
                    },
        			targets: 9
        		}], 
        	    serverSide: true,
        	    ajax: {
        	    	contentType: 'text/plain;charset=utf-8',
        	    	type: 'POST',
        	    	url: func_AjaxUrl(),
        	    	data: function(d){
        				d.extra_search = func_ajaxData();
        				return JSON.stringify(d);
        	    	}
        	    	
        			
        	    }
        	});
        	 function func_AjaxUrl(){
             	return path+"/ser/order/orderList";
             }
        	 /**
        	  *	后台查询条件
        	  */
        	 function func_ajaxData(){
        	 	var jsonObject = new Object();
        	 	if(orderNumber!=null&&orderNumber!=""){
           		 jsonObject.orderNumber=orderNumber;
           		 }
           		 if(storeId1!=null&&storeId1!=""){
           			 jsonObject.storeId=storeId1;
           		 }
           		 if(cashierId1!=null&&cashierId1!=""){
           			 jsonObject.cashierId=cashierId1;
           		 }
           		 if(startDate1!=null&&startDate1!=""){
           			 jsonObject.startDate=startDate1;
           		 }
           		 if(endDate1!=null&&endDate1!=""){
           			 jsonObject.endDate=endDate1;
           		 }
           		 jsonObject.flag=flag;
        	 	return jsonObject;
        	 }
             /**
              *	设置列名，对应后台
              */
             function func_columns(){
             	var jsonArr = [
             		{"data":"order_number"},
             		{"data":"trade_time"},
             		{"data":"store_name"},
             		{"data":"cashier_name"},
             		{"data":"goods_name"},
             		{"data":"purchase_quantity"},
             		{"data":"order_price"},
             		{"data":"consumer_phone"},
             		{"data":"flag"},
             		{"data":"tag_name"}
             	];
//              	JSON.parse()
             	return jsonArr;
             }
        }
        $(function(){      	
        	//$('#myTable').DataTable();  
        	myDataTable=dataTable();
        	setStore();
        });
        $(":checkbox").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",});
    	$("#commitSearch").click(function(){
			storeId1=$("#store_id1").val();
			cashierId1=$("#cashier_id1").val();
			startDate1=$("#startDate1").val();
			endDate1=$("#endDate1").val();
			orderNumber=$("#order_number").val();
			if($("#term1").is(":checked")){
				flag=1;
			}else if($("#term2").is(":checked")){
				flag=2;
			}else{
				flag=0;
			} 
			if($("#term1").is(":checked")&&$("#term2").is(":checked")){
				flag=3;
			}
			//console.log(storeId+"---"+cashierId+"---"+startDate+"----"+endDate+"-----"+orderNumber);
			myDataTable.ajax.reload();
		});
    	$("#closeSearch").click(function(){
    		$("#share_image1")[0].reset();
/*     		$("#order_number").prop("value","");
    		$("#startDate1").prop("value","");
    		$("#endDate1").prop("value","");
    		$("#store_id1 option:first").prop("selected", 'selected');
    		$("#cashier_id1 option:first").prop("selected", 'selected');
    		*/
    		$(".icheckbox_square-green").prop("class","icheckbox_square-green");
    		$("input [type='checkbox']").prop("checked",""); 
    		myDataTable.ajax.reload(); 
    	});
        function setStore(){
        	var option="";
        	$.ajax({
	            type: "POST",
	            async: false,
	            url: "${pageContext.request.contextPath}/api/account/getStores",
	            data: {
	            	"cid" : cid,
	            	"uid" : uid,
	            	"access_token" : access_token,
	            	"id":uid
	            	},
	            dataType: "json",
	            timeout: 1000,
	            success:function(data){	  
					if(data.data!=null){
		            	var storeInfo=data.data;
		            	for(var i=0;i<storeInfo.length;i++){
		            	option+="<option value="+storeInfo[i].store_id+">"+storeInfo[i].name+"</option>";
			            	if(i==0){
			            		setCashier("cashier_id",storeInfo[i].store_id);
			            		setCashier("cashier_id1",storeInfo[i].store_id);
			            	}
		            	}
		            	$("#store_id").html(option);
		            	$("#store_id1").html(option);
					}
	            }
	          });
        	
        }
        $("#store_id").change(function(){
        	 setCashier("cashier_id",$("#store_id").val());
        }); 
        $("#store_id1").change(function(){
       	 setCashier("cashier_id1",$("#store_id1").val());
       });
        function setCashier(name,data){
        	var option="";
        	$.ajax({
	            type: "POST",
	            async: false,
	            url: "${pageContext.request.contextPath}/api/account/getUsers",
	            data: {
	            	"cid" : cid,
	            	"uid" : uid,
	            	"access_token" : access_token,
	            	"id":data
	            	},
	            dataType: "json",
	            timeout: 1000,
	            success:function(data){	  
	            	var userList=data.data;
	            	option+="<option value=''>全部</option>";
	            	if(userList!=null&&userList.length>0){
		            	for(var i=0;i<userList.length;i++){
		            	$.ajax({
		    	            type: "POST",
		    	            async: false,
		    	            url: "${pageContext.request.contextPath}/api/account/getUserInfo",
		    	            data: {
		    	            	"cid" : cid,
		    	            	"uid" : uid,
		    	            	"access_token" : access_token,
		    	            	"id":userList[i].user_id
		    	            	},
			    	            success:function(data){
			    	            	data=JSON.parse(data);
			    	            	if(data.error_code!="10010"){
			    	            	option+="<option value="+userList[i].user_id+">"+data.data.name+"</option>";
			    	            	}
			    	            }
		    	            });
		    	        }
	            	}
	            	$("#"+name).html(option);
	            }
	          });
        }
		function getOrder(id){
			window.open(path+"/ser/ui/orderDetail?id="+id);
        }	
		function getChange(){
			var url=path+"/ser/order/getChange";
			$.post(url,{
				"access_token" : access_token,
        		"cid" : cid,
        		"uid" : uid},
        		function(data){
        		//console.log("---------->返回数据"+data);      		
        		 if(data!=null){
        			 var json=JSON.parse(data);
        			 getOrder(json.id);
        		 }       		
			});
		}
		$(function(){
			initDate();
			$(":checkbox").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",});
			$("#phone").keyup(function(){
				var phone = $(this).val();
				if(phone.length == 11){
					$.post(path+"/member/ajaxGetMemberByPhone",{phone:phone},function(data){
						//console.log(JSON.stringify(data));
						if(data.status == "200"){
							var member = data.data;
							if(member != null){						
								$("#name").val(member.name);
								$("#name").attr("readOnly","true");
								//console.log(member.gender);
								$(":radio[name='sex'][value='"+member.gender+"']").attr("checked",true);
								$(":radio[name='sex']").attr("disabled",true);
								var birthday = member.birthday;
								if(birthday != null && birthday != ""){
									var birthdayArr = birthday.split("-");
									$(".year").val(birthdayArr[0]).attr("disabled",true);
									$(".month").val(birthdayArr[1]).attr("disabled",true);
									func_getDay();
									$(".day").val(birthdayArr[2]).attr("disabled",true);
								}
								name=member.name;
								dataInit();
							}else{
								$("#name").attr("readOnly",false);
								$(":radio[name='sex']").attr("disabled",false);
								$(".year").attr("disabled",false);
								$(".month").attr("disabled",false);
								$(".day").attr("disabled",false);
							}
						}
					},"json");
				}
			});
		});

		function initDate(){
			func_getYear();
		    func_getMonth();
		    func_getDay();
		    //setInterval(getOrder,1000);
		}
		function func_getYear() {
		    var now = new Date();
		    var startYear = 1900;
		    var endYear = now.getFullYear();

		    var option = "";
		    for (; startYear <= endYear; startYear++) {
		        option += '<option value="' + startYear + '">' + startYear + '</option>';
		    }
		    $(".year").html(option);
		}

		function func_getMonth() {
		    var option = "";
		    for (var i = 1; i <= 12; i++) {
		        option += '<option value="' + i + '">' + i + '</option>';
		    }
		    $(".month").html(option);
		}

		function func_getDay() {
		    var year = $(".year:last").val();
		    var month = $(".month:last").val();

		    var now = new Date();
		    now.setFullYear(year);
		    now.setDate(1);
		    now.setMonth(month);
		    now.setDate(0);
		    var lastDay = now.getDate();

		    var option = "";
		    for (var i = 1; i <= lastDay; i++) {
		        option += '<option value="' + i + '">' + i + '</option>';
		    }
		    $(".day:last").html(option);
		}
    </script>
    <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
</body>
</html>
